﻿using INTEX.DataBase;
using INTEX.DataBase.Tools;
using ReflectionStudio.Core;
using ReflectionStudio.Core.Events;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using System.IO;
using System.Linq;
using System.Windows;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {

        public void UBTDXDOC(DataSet db)
        {
            try
            {

                DataTable dtSoruce = db.Tables["ICC_MKRF"];
                DataTable dtOutput = new DataTable();
                int idx = 1;
                double value=0;

                exAgent.SetCellValue(2, idx++, "排产机台"); dtOutput.Columns.Add("ABFBPOS", typeof(System.String));
                exAgent.SetCellValue(2, idx++, " "); dtOutput.Columns.Add("ABFAUFKRS", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "生产单"); dtOutput.Columns.Add("ABFAUFLFD", typeof(System.String));
                exAgent.SetCellValue(2, idx++, " "); dtOutput.Columns.Add("ABFAUFPOS", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "JOBTYPE"); dtOutput.Columns.Add("JOBTYPE", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "品种"); dtOutput.Columns.Add("ABPART", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "色号"); dtOutput.Columns.Add("ABPFARBE", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "后整理"); dtOutput.Columns.Add("ABPBESCHICH", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "整理方式"); dtOutput.Columns.Add("JP01", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "温度"); dtOutput.Columns.Add("JP02", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "配方"); dtOutput.Columns.Add("JP03", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "荧光"); dtOutput.Columns.Add("JP04", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "交期"); dtOutput.Columns.Add("JP05", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "色阶"); dtOutput.Columns.Add("JP06", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "首车"); dtOutput.Columns.Add("TPAUTO", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "布车"); dtOutput.Columns.Add("MKFTP", typeof(System.String));
                 exAgent.SetCellValue(2, idx++, "结束日期"); dtOutput.Columns.Add("MKFPLTIME", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "结束时间"); dtOutput.Columns.Add("ENDTIME", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "ABFAMASCHZT"); dtOutput.Columns.Add("ABFAMASCHZT", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "速度"); dtOutput.Columns.Add("ABFBASMGE", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "实际开始"); dtOutput.Columns.Add("ABFSOLLSTART", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "机台"); dtOutput.Columns.Add("ABFMLFDNR", typeof(System.String)); 
                exAgent.SetCellValue(2, idx++, "数量"); dtOutput.Columns.Add("MKFSMG1", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "ABAID"); dtOutput.Columns.Add("ABAID", typeof(System.String));
                exAgent.SetCellValue(2, idx++, "MKFSME"); dtOutput.Columns.Add("MKFSME", typeof(System.String));
                dtOutput.Merge(dtSoruce, false, MissingSchemaAction.Ignore);
                foreach (DataRow rx in dtOutput.Rows)
                { 
                     
                    rx["ABFBASMGE"] = System.Convert.ToDouble(rx["ABFBASMGE"].ToString().Trim()) * 0.001;
                    rx["MKFSMG1"] = System.Convert.ToDouble(rx["MKFSMG1"].ToString().Trim()) * 0.01;
                }
                exAgent.DataTableToExcel(dtOutput, 3, 1);
                
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            finally
            {
                EventDispatcher.Instance.RaiseStatus("完成", StatusEventType.StopProgress);
            }
        }

    }
}